﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HigLabo.CodeGenerator
{
    public class TypeName
    {
        public String Name { get; set; }
        public List<TypeName> GenericTypes { get; private set; }
        public TypeName(String name)
        {
            this.Name = name;
            this.GenericTypes = new List<TypeName>();
        }
        public String Write()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(this.Name);
            if (this.GenericTypes.Count > 0)
            {
                sb.Append("<");
                for (int i = 0; i < this.GenericTypes.Count; i++)
                {
                    var tp = this.GenericTypes[i];
                    sb.Append(tp.Write());
                    if (i < this.GenericTypes.Count - 1)
                    {
                        sb.Append(", ");
                    }
                }
                sb.Append(">");
            }
            return sb.ToString();
        }
    }
}
